//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Design;

namespace EntLibContrib.Query.Configuration
{
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

    /// <summary>
	/// Configuration data defining QueryData. Defines the information needed to properly configure
	/// a Query instance
	/// </summary>
	public abstract class QueryData : QueryDataBase
	{
		#region Constants
		private const string customCommandNameProperty = "customCommandName";
		private const string parameterSetNameProperty = "parameterSetName";
		#endregion

		#region Properties
		/// <summary>
		/// Gets or sets the command name.
		/// </summary>
        /// <value>The command name.</value>
		[ConfigurationProperty(customCommandNameProperty, IsRequired = false)]
        [Reference(typeof(NameTypeConfigurationElementCollection<CommandData, CustomCommandData>), typeof(CommandData))]
        [ResourceDescription(typeof(DesignResources), "CustomCommandNameDescription")]
        [ResourceDisplayName(typeof(DesignResources), "CustomCommandNameDisplayName")]
		public string CustomCommandName
		{
			get { return (string)base[customCommandNameProperty]; }
			set { base[customCommandNameProperty] = value; }
		}

		/// <summary>
		/// Gets or sets the parameter set name.
		/// </summary>
		/// <value>The parameter set name.</value>
		[ConfigurationProperty(parameterSetNameProperty, IsRequired = false)]
        [Reference(typeof(NamedElementCollection<ParameterSetData>), typeof(ParameterSetData))]
        [ResourceDescription(typeof(DesignResources), "ParameterSetNameDescription")]
        [ResourceDisplayName(typeof(DesignResources), "ParameterSetNameDisplayName")]
        public string ParameterSetName
		{
			get { return (string)base[parameterSetNameProperty]; }
			set { base[parameterSetNameProperty] = value; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initializes a new instance of the <see cref="QueryData"/> class.
		/// </summary>
		public QueryData ()
		{
		}

		/// <summary>
		/// Initialize a new instance of the <see cref="QueryData"/> class with a name and the type of <see cref="IQuery"/>.
		/// </summary>
		/// <param name="name">The name of the configured <see cref="IQuery"/>.</param>
		/// <param name="type">The type of <see cref="IQuery"/>.</param>
		protected QueryData(string name, Type type)
			: this(name, type, string.Empty, string.Empty)
		{
		}

		/// <summary>
		/// Initialize a new instance of the <see cref="QueryData"/> class with a name and the type of <see cref="IQuery"/>.
		/// </summary>
		/// <param name="name">The name of the configured <see cref="IQuery"/>.</param>
		/// <param name="type">The type of <see cref="IQuery"/>.</param>
		/// <param name="customCommandName">Name of the custom command.</param>
		/// <param name="parameterSetName">Name of the parameter set.</param>
		protected QueryData(string name, Type type, string customCommandName, string parameterSetName)
			: base(name, type)
		{
			this.CustomCommandName = customCommandName;
			this.ParameterSetName = parameterSetName;
		}
		#endregion

	}
}